<template>
	<view>
		<view class="edgeInsetTop"></view>
		<view class="cu-form-group" v-show="showAccNo">
			<view class="title">对公银行</view>
			<input type="text" placeholder="对公银行" disabled value="中国民生银行"></input>
		</view>
		<view class="cu-form-group" v-show="showAccNo">
			<view class="title">开户行支行</view>
			<input type="text" placeholder="开户行支行" disabled value="中国民生银行股份有限公司济南张庄路支行"></input>
		</view>
		<view class="cu-form-group" v-show="showAccNo">
			<view class="title">开户行代码</view>
			<input type="text" placeholder="开户行代码" disabled value="305451016162"></input>
		</view>
		<view class="cu-form-group" v-show="showAccNo">
			<view class="title">银行账户</view>
			<input @tap="copyOne('accNo')" type="number" placeholder="银行账户" disabled maxlength="20" v-model="user.accNo"></input>
		</view>
		<view class="cu-form-group" v-show="showAccNo">
			<view class="title">银行账户名称</view>
			<input @tap="copyOne('accName')" type="number" placeholder="银行账户名称" disabled maxlength="20" v-model="user.accName"></input>
		</view>
		
		<view class="padding-bj  margin-top" v-show="showAccNo">
			<button style="width:48%;margin-right:1.5%;" @tap="copy()" class="cu-btn wanl-bg-blue lg">复制打款信息</button>
			
			<button style="width: 48%;" @tap="$wanlshop.to('/pages/article/details?id=1&title=对公打款说明')" class="cu-btn wanl-bg-orange lg">对公打款说明</button>
		</view>
		
		<!-- <view class="padding-bj flex flex-direction margin-top" v-show="showAccNo">
			<button @tap="$wanlshop.to('/pages/article/details?id=1&title=对公打款说明')" class="cu-btn wanl-bg-orange lg">查看对公打款说明</button>
		</view> -->
		
		<view class="padding-bj flex flex-direction margin-top" v-show="!showAccNo">
			<button @tap="openAccount" class="cu-btn wanl-bg-orange lg">注册个人子账簿</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user: {
					accNo: "",
					accName: "",
				},
				showAccNo: 1
			}
		},
		onLoad(option) {
			let title = '充值 ';
			this.$wanlshop.title(title);
			
			this.loadData();
		},
		methods: {
			copy() {
				//uni.setClipboardData方法就是讲内容复制到粘贴板
			  uni.setClipboardData({
				data: this.user.copy_text,//要被复制的内容
				success:()=>{//复制成功的回调函数
				  this.$wanlshop.msg('复制成功!');
				}
			  });
			},
			copyOne(item) {
				if(item == 'accNo') {
					var copyData = this.user.accNo
				} else {
					var copyData = this.user.accName
				}
				uni.setClipboardData({
					data: copyData,//要被复制的内容
					success:()=>{//复制成功的回调函数
					  this.$wanlshop.msg('复制成功!');
					}
				});
			},
			loadData() {
				let that = this;
				uni.request({
					url: '/wanlshop/user/getUserAccInfo',
					method: 'POST',
					data: {},
					success: function(res) {
						console.log(res)
						if(res.res.code == 1) {
							that.showAccNo = 1;
							that.user = res.data;
						} else {
							that.showAccNo = 0;
						}
					}
				});
			},
			openAccount() {
				let that = this;
				uni.request({
					url: '/wanlshop/user/openAccount',
					method: 'POST',
					data: {},
					success: function(res) {
						console.log(res)
						if(res.res.code == 1) {
							this.$wanlshop.msg(res.res.msg,function(){
								that.loadData()
							});
						} else {
							this.$wanlshop.msg(res.res.msg);
						}
					}
				});
			}
		}
	}
</script>

<style>
	.cu-form-group {
		padding: 0 25rpx;
	}
	/* 1.1.5升级 */
	.cu-form-group.area{
		position: relative;
	}
	.cu-form-group.area .click{
		position: absolute;
		z-index: 99;
		right: 0;
		left: 0;
		top: 0;
		bottom: 0;
	}
	.cu-form-group .title {
		min-width: calc(4em + 15px);
		font-size: 26rpx;
	}

	.cu-form-group input,
	.cu-form-group textarea {
		font-size: 26rpx;
	}

	.cu-btn.lg {
		font-size: 32rpx;
		height: 86rpx;
	}

	.tipsScroll {
		width: 100%;
		height: 500rpx;
		padding: 0 50rpx;
	}

	.tipsScroll .item {
		margin: 25rpx 0;
	}

	.tipsScroll .item view {
		color: #B8B8B8;
		font-size: 22rpx;
	}

	.tipsScroll .item text {
		color: #333;
	}
</style>
